package com.example.scaffolding.db;

import android.content.Context;

import androidx.room.Room;

public class DataBaseInstance {

    private static volatile MyDataBase INSTANCE;

    public static MyDataBase getINSTANCE(Context context) {
        if (INSTANCE == null) {
            synchronized (DataBaseInstance.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(context, MyDataBase.class,
                            "room").allowMainThreadQueries().build();
                }
            }
        }
        return INSTANCE;
    }

    /**
     * prevent the context leak
     */
    public static void setINSTANCEtoNull() {
        INSTANCE = null;
    }


}
